#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>


int main(int argc, char const* argv[])
{
	int fd_mem;
	unsigned char *base;

//	printf("%lx\n", ID);

	if ((fd_mem = open("/dev/mem", O_RDWR | O_NDELAY)) == -1) 
	{
		perror ("/dev/mem");
		return -1;
	}

	base= (unsigned char *)
		mmap (NULL,  4*1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd_mem, 0x4830a000);
	printf("base: %08x%08x%08x%08x\n", *(volatile long *)(base+0x224), *(volatile long *)(base+0x220), *(volatile long *)(base+0x21c), *(volatile long *)(base+0x218));
	int i = 0;
	for (i=0x227; i>=0x218; --i) {
		printf("%02x", *(volatile char *)(base+i));
	}
	printf("\n\n");
	printf("%02x\n", *(volatile char *)(base+0x227));
	printf("%02x\n", *(volatile char *)(base+0x226));
	printf("%02x\n", *(volatile char *)(base+0x225));
	printf("%02x\n", *(volatile char *)(base+0x224));

	printf("%02x\n", *(volatile char *)(base+0x223));
	printf("%02x\n", *(volatile char *)(base+0x222));
	printf("%02x\n", *(volatile char *)(base+0x221));
	printf("%02x\n", *(volatile char *)(base+0x220));

	printf("%02x\n", *(volatile char *)(base+0x21f));
	printf("%02x\n", *(volatile char *)(base+0x21e));
	printf("%02x\n", *(volatile char *)(base+0x21d));
	printf("%02x\n", *(volatile char *)(base+0x21c));

	printf("%02x\n", *(volatile char *)(base+0x21b));
	printf("%02x\n", *(volatile char *)(base+0x21a));
	printf("%02x\n", *(volatile char *)(base+0x219));
	printf("%02x\n", *(volatile char *)(base+0x218));
	printf("\nEND\n");

	return 0;
}
